<template>
  <el-container>
    <el-header>
      <div class="h1" style="display: flex">
        <span style="margin-top: 40px">用户名:</span>
        <div style="margin-top: 39px;margin-left: 5px">{{username}}</div>
      </div>
    </el-header>
    <el-main>
      <div class="m1">
        <el-tabs v-model="activeName" @tab-click="handleClick()">
          <el-tab-pane label="资金情况" name="first">
            <div class="app-container">
<!--              <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">-->
<!--                <el-form-item label="用户id" prop="userId">-->
<!--                  <el-input-->
<!--                    v-model="queryParams.userId"-->
<!--                    placeholder="请输入用户id"-->
<!--                    clearable-->
<!--                    @keyup.enter.native="handleQuery"-->
<!--                  />-->
<!--                </el-form-item>-->
<!--                <el-form-item label="资金" prop="money">-->
<!--                  <el-input-->
<!--                    v-model="queryParams.money"-->
<!--                    placeholder="请输入资金"-->
<!--                    clearable-->
<!--                    @keyup.enter.native="handleQuery"-->
<!--                  />-->
<!--                </el-form-item>-->
<!--                <el-form-item>-->
<!--                  <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>-->
<!--                  <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>-->
<!--                </el-form-item>-->
<!--              </el-form>-->

              <el-row :gutter="10" class="mb8">
                <el-col :span="1.5">
                  <el-button
                    type="primary"
                    plain
                    icon="el-icon-plus"
                    size="mini"
                    @click="handleAdd"
                    v-hasPermi="['money:money:add']"
                  >新增</el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="success"
                    plain
                    icon="el-icon-edit"
                    size="mini"
                    :disabled="single"
                    @click="handleUpdate"
                    v-hasPermi="['money:money:edit']"
                  >修改</el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="danger"
                    plain
                    icon="el-icon-delete"
                    size="mini"
                    :disabled="multiple"
                    @click="handleDelete"
                    v-hasPermi="['money:money:remove']"
                  >删除</el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="warning"
                    plain
                    icon="el-icon-download"
                    size="mini"
                    @click="handleExport"
                    v-hasPermi="['money:money:export']"
                  >导出</el-button>
                </el-col>
                <right-toolbar :showSearch.sync="showSearch" @queryTable="getMoneyByUser"></right-toolbar>
              </el-row>

              <el-table v-loading="loading" :data="moneyList" @selection-change="handleSelectionChange">
                <el-table-column type="selection" width="55" align="center" />
                <el-table-column label="资金ID" align="center" prop="moneyId" />
<!--                <el-table-column label="用户id" align="center" prop="userId" />-->
                <el-table-column label="资金" align="center" prop="money" />
                <el-table-column label="资金类型" align="center" prop="type" />
                <el-table-column label="状态" align="center" prop="status" />
                <el-table-column label="备注信息" align="center" prop="remark" />
                <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                  <template slot-scope="scope">
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-edit"
                      @click="handleUpdate(scope.row)"
                      v-hasPermi="['money:money:edit']"
                    >修改</el-button>
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-delete"
                      @click="handleDelete(scope.row)"
                      v-hasPermi="['money:money:remove']"
                    >删除</el-button>
                  </template>
                </el-table-column>
              </el-table>

              <pagination
                v-show="total>0"
                :total="total"
                :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize"
                @pagination="getMoneyByUser"
              />

              <!-- 添加或修改用户流水对话框 -->
              <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
                <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<!--                  <el-form-item label="用户id" prop="userId">-->
<!--                    <el-input v-model="form.userId" placeholder="请输入用户id" />-->
<!--                  </el-form-item>-->
                  <el-form-item label="资金" prop="money">
                    <el-input v-model="form.money" placeholder="请输入资金" />
                  </el-form-item>
                  <el-form-item label="类型" prop="type">
                    <el-input v-model="form.type" placeholder="请输入资金类型" />
                  </el-form-item>
                  <el-form-item label="状态" prop="status">
                    <el-input v-model="form.status" placeholder="请输入状态" />
                  </el-form-item>
                  <el-form-item label="备注信息" prop="remark">
                    <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
                  </el-form-item>
<!--                  <el-form-item label="是否删除" prop="delFlag">-->
<!--                    <el-input v-model="form.delFlag" placeholder="请输入是否删除" />-->
<!--                  </el-form-item>-->
                </el-form>
                <div slot="footer" class="dialog-footer">
                  <el-button type="primary" @click="submitForm">确 定</el-button>
                  <el-button @click="cancel">取 消</el-button>
                </div>
              </el-dialog>
            </div>
          </el-tab-pane>

          <el-tab-pane label="订单管理" name="second">
            <div class="app-container">
<!--              <el-form :model="orderParams" ref="orderForm" size="small" :inline="true" v-show="showSearch" label-width="68px">-->
<!--&lt;!&ndash;                <el-form-item label="用户id" prop="userId">&ndash;&gt;-->
<!--&lt;!&ndash;                  <el-input&ndash;&gt;-->
<!--&lt;!&ndash;                    v-model="orderParams.userId"&ndash;&gt;-->
<!--&lt;!&ndash;                    placeholder="请输入用户id"&ndash;&gt;-->
<!--&lt;!&ndash;                    clearable&ndash;&gt;-->
<!--&lt;!&ndash;                    @keyup.enter.native="orderQuery"&ndash;&gt;-->
<!--&lt;!&ndash;                  />&ndash;&gt;-->
<!--&lt;!&ndash;                </el-form-item>&ndash;&gt;-->
<!--                <el-form-item label="用户名" prop="userName">-->
<!--                  <el-input-->
<!--                    v-model="orderParams.userName"-->
<!--                    placeholder="请输入用户名"-->
<!--                    clearable-->
<!--                    @keyup.enter.native="orderQuery"-->
<!--                  />-->
<!--                </el-form-item>-->
<!--                <el-form-item label="订单编号" prop="orderNo">-->
<!--                  <el-input-->
<!--                    v-model="orderParams.orderNo"-->
<!--                    placeholder="请输入订单编号"-->
<!--                    clearable-->
<!--                    @keyup.enter.native="orderQuery"-->
<!--                  />-->
<!--                </el-form-item>-->
<!--                <el-form-item label="支付金额" prop="price">-->
<!--                  <el-input-->
<!--                    v-model="orderParams.price"-->
<!--                    placeholder="请输入支付金额"-->
<!--                    clearable-->
<!--                    @keyup.enter.native="orderQuery"-->
<!--                  />-->
<!--                </el-form-item>-->
<!--                <el-form-item label="支付方式" prop="way">-->
<!--                  <el-input-->
<!--                    v-model="orderParams.way"-->
<!--                    placeholder="请输入支付方式"-->
<!--                    clearable-->
<!--                    @keyup.enter.native="orderQuery"-->
<!--                  />-->
<!--                </el-form-item>-->
<!--&lt;!&ndash;                <el-form-item label="地址id" prop="addressId">&ndash;&gt;-->
<!--&lt;!&ndash;                  <el-input&ndash;&gt;-->
<!--&lt;!&ndash;                    v-model="orderParams.addressId"&ndash;&gt;-->
<!--&lt;!&ndash;                    placeholder="请输入地址id"&ndash;&gt;-->
<!--&lt;!&ndash;                    clearable&ndash;&gt;-->
<!--&lt;!&ndash;                    @keyup.enter.native="orderQuery"&ndash;&gt;-->
<!--&lt;!&ndash;                  />&ndash;&gt;-->
<!--&lt;!&ndash;                </el-form-item>&ndash;&gt;-->
<!--                <el-form-item label="所在地址" prop="address">-->
<!--                  <el-input-->
<!--                    v-model="orderParams.address"-->
<!--                    placeholder="请输入所在地址"-->
<!--                    clearable-->
<!--                    @keyup.enter.native="orderQuery"-->
<!--                  />-->
<!--                </el-form-item>-->
<!--                <el-form-item>-->
<!--                  <el-button type="primary" icon="el-icon-search" size="mini" @click="orderQuery">搜索</el-button>-->
<!--                  <el-button icon="el-icon-refresh" size="mini" @click="resetOrderQuery">重置</el-button>-->
<!--                </el-form-item>-->
<!--              </el-form>-->

              <el-row :gutter="10" class="mb8">
                <el-col :span="1.5">
                  <el-button
                    type="primary"
                    plain
                    icon="el-icon-plus"
                    size="mini"
                    @click="orderAdd"
                    v-hasPermi="['order:order:add']"
                  >新增</el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="success"
                    plain
                    icon="el-icon-edit"
                    size="mini"
                    :disabled="single"
                    @click="orderUpdate"
                    v-hasPermi="['order:order:edit']"
                  >修改</el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="danger"
                    plain
                    icon="el-icon-delete"
                    size="mini"
                    :disabled="multiple"
                    @click="submitOrderForm"
                    v-hasPermi="['order:order:remove']"
                  >删除</el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="warning"
                    plain
                    icon="el-icon-download"
                    size="mini"
                    @click="orderExport"
                    v-hasPermi="['order:order:export']"
                  >导出</el-button>
                </el-col>
                <right-toolbar :showSearch.sync="showSearch" @queryTable="getOrderByUser"></right-toolbar>
              </el-row>

              <el-table v-loading="loading" :data="orderList" @selection-change="orderSelectionChange">
                <el-table-column type="selection" width="55" align="center" />
                <el-table-column label="订单ID" align="center" prop="orderId" />
                <el-table-column label="用户id" align="center" prop="userId" />
                <el-table-column label="用户名" align="center" prop="userName" />
                <el-table-column label="订单编号" align="center" prop="orderNo" />
                <el-table-column label="支付金额" align="center" prop="price" />
                <el-table-column label="支付方式" align="center" prop="way" />
<!--                <el-table-column label="类型" align="center" prop="type" />-->
<!--                <el-table-column label="地址id" align="center" prop="addressId" />-->
                <el-table-column label="所在地址" align="center" prop="address" />
                <el-table-column label="备注信息" align="center" prop="remark" />
                <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                  <template slot-scope="scope">
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-edit"
                      @click="orderDetail(scope.row)"
                    >查看</el-button>
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-edit"
                      @click="orderUpdate(scope.row)"
                      v-hasPermi="['order:order:edit']"
                    >修改</el-button>
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-delete"
                      @click="orderDelete(scope.row)"
                      v-hasPermi="['order:order:remove']"
                    >删除</el-button>
                  </template>
                </el-table-column>
              </el-table>

              <pagination
                v-show="total>0"
                :total="total"
                :page.sync="orderParams.pageNum"
                :limit.sync="orderParams.pageSize"
                @pagination="getOrderByUser"
              />

              <!-- 添加或修改用户订单对话框 -->
              <el-dialog :title="title" :visible.sync="orderopen" width="500px" append-to-body>
                <el-form ref="orderform" :model="orderform" :rules="rules" label-width="80px">
<!--                  <el-form-item label="用户id" prop="userId">-->
<!--                    <el-input v-model="orderform.userId" placeholder="请输入用户id" />-->
<!--                  </el-form-item>-->
<!--                  <el-form-item label="用户名" prop="userName">-->
<!--                    <el-input v-model="orderform.userName" placeholder="请输入用户名" />-->
<!--                  </el-form-item>-->
                  <el-form-item label="订单编号" prop="orderNo">
                    <el-input v-model="orderform.orderNo" placeholder="请输入订单编号" />
                  </el-form-item>
                  <el-form-item label="支付金额" prop="price">
                    <el-input v-model="orderform.price" placeholder="请输入支付金额" />
                  </el-form-item>
                  <el-form-item label="支付方式" prop="way">
                    <el-input v-model="orderform.way" placeholder="请输入支付方式" />
                  </el-form-item>
<!--                  <el-form-item label="地址id" prop="addressId">-->
<!--                    <el-input v-model="orderform.addressId" placeholder="请输入地址id" />-->
<!--                  </el-form-item>-->
                  <el-form-item label="所在地址" prop="address">
                    <el-input v-model="orderform.address" placeholder="请输入所在地址" />
                  </el-form-item>
                  <el-form-item label="备注信息" prop="remark">
                    <el-input v-model="orderform.remark" type="textarea" placeholder="请输入内容" />
                  </el-form-item>
<!--                  <el-form-item label="是否删除" prop="delFlag">-->
<!--                    <el-input v-model="orderform.delFlag" placeholder="请输入是否删除" />-->
<!--                  </el-form-item>-->
                </el-form>
                <div slot="footer" class="dialog-footer">
                  <el-button type="primary" @click="submitOrderForm">确 定</el-button>
                  <el-button @click="ordercancel">取 消</el-button>
                </div>
              </el-dialog>
            </div>
          </el-tab-pane>

          <el-tab-pane label="接收通知" name="third">
            <div class="app-container">
<!--              <el-form :model="noticeParams" ref="noticeForm" size="small" :inline="true" v-show="showSearch" label-width="68px">-->
<!--                <el-form-item label="用户id" prop="userId">-->
<!--                  <el-input-->
<!--                    v-model="noticeParams.userId"-->
<!--                    placeholder="请输入接收用户id"-->
<!--                    clearable-->
<!--                    @keyup.enter.native="noticeQuery"-->
<!--                  />-->
<!--                </el-form-item>-->
<!--                <el-form-item label="发布时间" prop="publishTime">-->
<!--                  <el-date-picker clearable-->
<!--                                  v-model="noticeParams.publishTime"-->
<!--                                  type="date"-->
<!--                                  value-format="yyyy-MM-dd"-->
<!--                                  placeholder="请选择发布时间">-->
<!--                  </el-date-picker>-->
<!--                </el-form-item>-->
<!--                <el-form-item>-->
<!--                  <el-button type="primary" icon="el-icon-search" size="mini" @click="noticeQuery">搜索</el-button>-->
<!--                  <el-button icon="el-icon-refresh" size="mini" @click="resetNoticeQuery">重置</el-button>-->
<!--                </el-form-item>-->
<!--              </el-form>-->

              <el-row :gutter="10" class="mb8">
                <el-col :span="1.5">
                  <el-button
                    type="primary"
                    plain
                    icon="el-icon-plus"
                    size="mini"
                    @click="noticeAdd"
                    v-hasPermi="['notice:notice:add']"
                  >新增</el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="success"
                    plain
                    icon="el-icon-edit"
                    size="mini"
                    :disabled="single"
                    @click="noticeUpdate"
                    v-hasPermi="['notice:notice:edit']"
                  >修改</el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="danger"
                    plain
                    icon="el-icon-delete"
                    size="mini"
                    :disabled="multiple"
                    @click="noticeDelete"
                    v-hasPermi="['notice:notice:remove']"
                  >删除</el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="warning"
                    plain
                    icon="el-icon-download"
                    size="mini"
                    @click="noticeExport"
                    v-hasPermi="['notice:notice:export']"
                  >导出</el-button>
                </el-col>
                <right-toolbar :showSearch.sync="showSearch" @queryTable="getNoticeList"></right-toolbar>
              </el-row>

              <el-table v-loading="loading" :data="noticeList" @selection-change="noticeSelectionChange">
                <el-table-column type="selection" width="55" align="center" />
                <el-table-column label="任务ID" align="center" prop="noticeId" />
<!--                <el-table-column label="接收用户id" align="center" prop="userId" />-->
                <el-table-column label="通知类型(系统，公司，新闻)" align="center" prop="type" />
                <el-table-column label="发布时间" align="center" prop="publishTime" width="180">
                  <template slot-scope="scope">
                    <span>{{ parseTime(scope.row.publishTime, '{y}-{m}-{d}') }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备注信息" align="center" prop="remark" />
                <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                  <template slot-scope="scope">
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-edit"
                      @click="noticeDetail(scope.row)"
                    >查看</el-button>
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-edit"
                      @click="noticeUpdate(scope.row)"
                      v-hasPermi="['notice:notice:edit']"
                    >修改</el-button>
                    <el-button
                      size="mini"
                      type="text"
                      icon="el-icon-delete"
                      @click="noticeDelete(scope.row)"
                      v-hasPermi="['notice:notice:remove']"
                    >删除</el-button>
                  </template>
                </el-table-column>
              </el-table>

              <pagination
                v-show="total>0"
                :total="total"
                :page.sync="noticeParams.pageNum"
                :limit.sync="noticeParams.pageSize"
                @pagination="getNoticeList"
              />

              <!-- 添加或修改系统通知对话框 -->
              <el-dialog :title="title" :visible.sync="noticeopen" width="500px" append-to-body>
                <el-form ref="noticeform" :model="noticeform" :rules="rules" label-width="80px">
<!--                  <el-form-item label="接收用户id" prop="userId">-->
<!--                    <el-input v-model="noticeform.userId" placeholder="请输入接收用户id" />-->
<!--                  </el-form-item>-->
<!--                  <el-form-item label="接收用户" prop="userId">-->
<!--                    <el-input v-model="noticeform.nickName" placeholder="请输入接收用户" />-->
<!--                  </el-form-item>-->
                  <el-form-item label="发布时间" prop="publishTime">
                    <el-date-picker clearable
                                    v-model="noticeform.publishTime"
                                    type="date"
                                    value-format="yyyy-MM-dd"
                                    placeholder="请选择发布时间">
                    </el-date-picker>
                  </el-form-item>
                  <el-form-item label="通知内容" prop="remark">
                    <el-input v-model="noticeform.content" type="textarea" placeholder="请输入内容" />
                  </el-form-item>
                  <el-form-item label="备注信息" prop="remark">
                    <el-input v-model="noticeform.remark" type="textarea" placeholder="请输入内容" />
                  </el-form-item>
                  <el-form-item label="是否删除" prop="delFlag">
                    <el-input v-model="noticeform.delFlag" placeholder="请输入是否删除" />
                  </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                  <el-button type="primary" @click="submitNoticeForm">确 定</el-button>
                  <el-button @click="noticecancel">取 消</el-button>
                </div>
              </el-dialog>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </el-main>
  </el-container>
</template>

<script>
import {getUser} from "@/api/system/user";
import {getMoney, delMoney, addMoney, updateMoney, getMoneyByUserId} from "@/api/scp/money";
import {addOrder, delOrder, getOrder, listOrder, updateOrder,getOrderByUserId} from "@/api/scp/order";
import { listNotice, getNotice, delNotice, addNotice, updateNotice,getNoticeByUserId } from "@/api/scp/notice";
export default {
  name: "userDetail",
  data(){
    return {
      username:"",
      activeName: 'first',
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户流水表格数据
      moneyList: [],
      // 用户订单表格数据
      orderList: [],
      // 通知公告表格数据
      noticeList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      orderopen:false,
      noticeopen:false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
        money: null,
        type: null,
        status: null
      },
      orderParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
        userName: null,
        orderNo: null,
        price: null,
        way: null,
        type: null,
        addressId: null,
        address: null,
      },
      // 查询参数
      noticeParams: {
        pageNum: 1,
        pageSize: 10,
        userId: null,
        type: null,
        publishTime: null,
      },
      // 表单参数
      form: {},
      orderform:{},
      noticeform: {},
      // 表单校验
      rules: {
      },
    }
  },
  created() {
    this.getUserName()
    this.getMoneyByUser();
    this.getOrderByUser();
    this.getNoticeByUser();
  },
  methods: {
    getUserName(){
      var userId = this.$route.query.userId
      getUser(userId).then(res=>{
        this.username = res.data.nickName
      })
    },
    getMoneyByUser(){
      this.loading = true;
      var userId = this.$route.query.userId
      getMoneyByUserId(userId).then(response=>{
        this.moneyList = response.rows;
        this.total = response.total;
        this.loading = false;
      })
    },
    getNoticeByUser(){
      this.loading = true;
      var userId = this.$route.query.userId
      getNoticeByUserId(userId).then(response=>{
        this.noticeList = response.rows;
        this.total = response.total;
        this.loading = false;
      })
    },
    getOrderByUser(){
      this.loading = true;
      var userId = this.$route.query.userId
      getOrderByUserId(userId).then(response=>{
        this.orderList = response.rows;
        this.total = response.total;
        this.loading = false;
      })
    },
    /** 查询用户流水列表 */
    // getList() {
    //   listMoney(this.queryParams).then(response => {
    //     this.moneyList = response.rows;
    //     this.total = response.total;
    //     this.loading = false;
    //   });
    // },
    /** 查询用户订单列表 */
    getOrderList() {
      this.orderList.userId = this.$route.query.userId
      this.loading = true;
      listOrder(this.orderParams).then(response => {
        this.orderList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        moneyId: null,
        userId: null,
        money: null,
        type: null,
        status: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        delFlag: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    // handleQuery() {
    //   this.queryParams.pageNum = 1;
    //   this.getMoneyByUser();
    // },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.moneyId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加用户流水";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const moneyId = row.moneyId || this.ids
      getMoney(moneyId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改用户流水";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.moneyId != null) {
            updateMoney(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getMoneyByUser();
            });
          } else {
            this.form.userId = this.$route.query.userId
            addMoney(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getMoneyByUser();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const moneyIds = row.moneyId || this.ids;
      this.$modal.confirm('是否确认删除用户流水编号为"' + moneyIds + '"的数据项？').then(function() {
        return delMoney(moneyIds);
      }).then(() => {
        this.getMoneyByUser();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('money/money/export', {
        ...this.queryParams
      }, `money_${new Date().getTime()}.xlsx`)
    },
    // 取消按钮
    ordercancel() {
      this.orderopen = false;
      this.orderreset();
    },
    // 表单重置
    orderreset() {
      this.orderform = {
        orderId: null,
        userId: null,
        userName: null,
        orderNo: null,
        price: null,
        way: null,
        type: null,
        addressId: null,
        address: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        delFlag: null
      };
      this.resetForm("orderform");
    },
    /** 搜索按钮操作 */
    orderQuery() {
      this.orderParams.pageNum = 1;
      this.getOrderByUser();
    },
    /** 重置按钮操作 */
    resetOrderQuery() {
      this.resetForm("orderForm");
      this.orderQuery();
    },
    // 多选框选中数据
    orderSelectionChange(selection) {
      this.ids = selection.map(item => item.orderId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    //查看订单详情操作
    orderDetail(row){
      const orderId = row.orderId || this.ids
      getOrder(orderId).then(response=>{
        this.$router.push({
          path:"/order/orderDetail",
          query:{
            orderId:orderId
          }
        })
      })
    },
    /** 新增按钮操作 */
    orderAdd() {
      this.orderreset();
      this.orderopen = true;
      this.title = "添加用户订单";
    },
    /** 修改按钮操作 */
    orderUpdate(row) {
      this.orderreset();
      const orderId = row.orderId || this.ids
      getOrder(orderId).then(response => {
        this.orderform = response.data.order;
        this.orderopen = true;
        this.title = "修改用户订单";
      });
    },
    /** 提交按钮 */
    submitOrderForm() {
      this.$refs["orderform"].validate(valid => {
        if (valid) {
          if (this.orderform.orderId != null) {
            updateOrder(this.orderform).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.orderopen = false;
              this.getOrderByUser();
            });
          } else {
            this.orderform.userId = this.$route.query.userId
            this.orderform.userName = this.username
            console.log(this.orderform)
            addOrder(this.orderform).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.orderopen = false;
              this.getOrderByUser();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    orderDelete(row) {
      const orderIds = row.orderId || this.ids;
      this.$modal.confirm('是否确认删除用户订单编号为"' + orderIds + '"的数据项？').then(function() {
        return delOrder(orderIds);
      }).then(() => {
        this.getOrderByUser();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    orderExport() {
      this.download('order/order/export', {
        ...this.orderParams
      }, `order_${new Date().getTime()}.xlsx`)
    },
    handleClick(tab, event) {
      // console.log(tab, event);
    },
    /** 查询系统通知列表 */
    getNoticeList() {
      this.loading = true;
      listNotice(this.noticeParams).then(response => {
        this.noticeList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    noticecancel() {
      this.noticeopen = false;
      this.noticereset();
    },
    // 表单重置
    noticereset() {
      this.noticeform = {
        noticeId: null,
        userId: null,
        type: null,
        publishTime: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        delFlag: null
      };
      this.resetForm("noticeform");
    },
    /** 搜索按钮操作 */
    noticeQuery() {
      this.noticeParams.pageNum = 1;
      this.getNoticeList();
    },
    /** 重置按钮操作 */
    resetNoticeQuery() {
      this.resetForm("noticeForm");
      this.noticeQuery();
    },
    // 多选框选中数据
    noticeSelectionChange(selection) {
      this.ids = selection.map(item => item.noticeId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    noticeDetail(row){
      this.$router.push({path:"/scp/setting/notice/open?noticeId="+row.noticeId})
      // this.$router.push({
      //   path:"/scp/setting/notice/open",
      //   query:{
      //     noticeId:row.noticeId
      //   }
      // })
    },
    /** 新增按钮操作 */
    noticeAdd() {
      this.noticereset();
      this.noticeopen = true;
      this.title = "添加系统通知";
    },
    /** 修改按钮操作 */
    noticeUpdate(row) {
      this.noticereset();
      const noticeId = row.noticeId || this.ids
      getNotice(noticeId).then(response => {
        this.noticeform = response.data;
        this.noticeopen = true;
        this.title = "修改系统通知";
      });
    },
    /** 提交按钮 */
    submitNoticeForm() {
      this.$refs["noticeform"].validate(valid => {
        if (valid) {
          if (this.noticeform.noticeId != null) {
            updateNotice(this.noticeform).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.noticeopen = false;
              this.getNoticeList();
            });
          } else {
            this.noticeform.userId = this.$route.query.userId
            this.noticeform.userName = this.username
            this.noticeform.type = '系统'
            addNotice(this.noticeform).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.noticeopen = false;
              this.getNoticeList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    noticeDelete(row) {
      const noticeIds = row.noticeId || this.ids;
      this.$modal.confirm('是否确认删除系统通知编号为"' + noticeIds + '"的数据项？').then(function() {
        return delNotice(noticeIds);
      }).then(() => {
        this.getNoticeList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    noticeExport() {
      this.download('notice/notice/export', {
        ...this.noticeParams
      }, `notice_${new Date().getTime()}.xlsx`)
    }
  }
}
</script>
<style>
.el-header {
  /*background-color: #B3C0D1;*/
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-main {
  /*background-color: #E9EEF3;*/
  color: #333;
}

body > .el-container {
  margin-bottom: 40px;
}
</style>
